﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProjectChords.Services.API;
using ProjectChords.Services.Models;

namespace ProjectChords.Services.Impl.Memory
{
    /// <summary>
    /// This class extends the GenericInMemoryService to reuse the CRUD implementation and the constrained searching
    /// functionality for the ContentItem objects
    /// It also implements further methods defined in the interface: IContentService.
    /// </summary>
    public class ContentServiceInMemoryImpl : GenericInMemoryService<ContentItem>, IContentService
    {
        public ContentServiceInMemoryImpl()
            : base()
        {
        }

        /// <summary>
        /// Returns an empty list if no matching categories are found.
        /// </summary>
        /// <param name="contentCategoryId">Unique id of the ContentCategory objectr</param>
        /// <returns>A list containing all ContentItem objects that have matching ContentCategory</returns>
        public List<ContentItem> GetAllContentItemsForGivenCategory(string contentCategoryId)
        {
            return base.GetAllItemsForGivenConstraint(contentCategoryId);
        }

        public List<ContentItem> GetAllContentItemsForGivenCategoryAndItsSubCategories(string parentContentCategoryId)
        {
            // Generate the list of relavant categories
            // call GetAllContentItemsForGivenCategory for each category.
            // Union the results

            throw new NotImplementedException();
        }

        public override string GetConstraintValue(ContentItem obj)
        {
            return obj.Category.Id;
        }
    }
}
